<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<link rel="stylesheet" th:href="@{/Bootstrapfileinput/css/theme.min.css}" />
<link rel="stylesheet" th:href="@{/Bootstrapfileinput/css/fileinput.min.css}" />
<link th:href="@{/ajax/libs/jquery-layout/jquery.layout-latest.css}" rel="stylesheet"/>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-wechatProductAttribute-add">
        	<input name="productCategoryId" type="hidden" id="treeId"/>
            <input name="parentId"  type="hidden" id="parentId"/>
			<div class="form-group">	
				<label class="col-sm-3 control-label">商品类别：</label>
				<div class="col-sm-8">
					<div class="input-group">
                    	<input name="productCategoryName" onclick="selectProductCategoryTree()" id="treeName" type="text" placeholder="请选择类目" class="form-control" required>
                        <span class="input-group-addon"><i class="fa fa-search"></i></span>
                    </div>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">属性标题 ：</label>
				<div class="col-sm-8">
					<input id="title" name="title" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">属性全称：</label>
				<div class="col-sm-8">
					<input id="name" name="name" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">属性代码：</label>
				<div class="col-sm-8">
					<input id="code" name="code" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">属性描述 ：</label>
				<div class="col-sm-8">
					<input id="description" name="description" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">属性预设内容：</label>
				<div class="col-sm-8">
					<input id="content" name="content" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">属性默认值：</label>
				<div class="col-sm-8">
					<input id="value" name="value" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">排列次序：</label>
				<div class="col-sm-8">
					<input id="orders" name="orders" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">状态：</label>
				<div class="col-sm-8">
					<select id="status" name="status"  class="form-control" th:with="type=${@dict.getType('wechat_product_brand_status')}">
					  <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}">
					  </option>
					</select>
				</div>
			</div>
		</form>
	</div>
    <div th:include="include::footer"></div>
	<script th:src="@{/ajax/libs/select/select2.js}"></script>
    <script type="text/javascript">
		var prefix = ctx + "wechat/wechatProductAttribute"
		/*类目选择*/
        function selectProductCategoryTree() {
        	var treeId = $("#treeId").val();
        	var productCategoryId = $.common.isEmpty(treeId) ? "1" : $("#treeId").val();
			var options = {
				title: '选择类目',
				width: "380",
				url: ctx + "wechat/wechatShopProductCategory/selectChannelTree/" + productCategoryId,
				callBack: doSubmit
			};
			$.modal.openOptions(options);
		}
		
        function doSubmit(index, layero){
			var tree = layero.find("iframe")[0].contentWindow.$._tree;
			if ($.tree.notAllowParents(tree)) {
				var body = layer.getChildFrame('body', index);
    			$("#treeId").val(body.find('#treeId').val());
    			$("#treeName").val(body.find('#treeName').val());
    			$("#productCategoryName").val(body.find('#treeName').val());
    			layer.close(index);
			}
		}
		
		function submitHandler() {
	        $.operate.save(prefix + "/add", $('#form-wechatProductAttribute-add').serialize());
	    }
	</script>
</body>
</html>
